<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<title><fmt:message key="CodeGenerator.title"/> </title>
<menu><fmt:message key="menu.generator.title"/></menu>
<submenu><fmt:message key="menu.generator.title"/></submenu>
<script>
$(".codeGenerator").addClass("active").parent("ul").parent("li").addClass("active open");

$(document).ready(function(){
	checkAllRecord("#checkAll",".checkitems")
	$("#nextButton").click(function(){
		var checked=[];
		$('input[name="tableNames"]:checked').each(function(){
			checked.push($(this).val());
		})
		if(checked.length == 0){
			alert('<fmt:message key="error.CodeGenerator.selectatleastone"/>');
			return;
		}
		$("#selectTableForm").submit();
	})
})
</script>
<div class="widget-box">
	<div class="widget-header widget-header-blue widget-header-flat">
		<h4 class="widget-title lighter"><fmt:message key="CodeGenerator.title"/></h4>
	</div>
	
	<div class="widget-body">
		<div class="widget-main">
			<div id="fuelux-wizard-container">
				
				<jsp:include page="generatorStep.jsp"></jsp:include>
				<script>
					$(".step1").addClass("active");
					<c:if test="${message != null || messageKey != null}">
					$(".step2").addClass("active");
					$(".step3").addClass("active");
					$(".step4").addClass("active");
					</c:if>
				</script>
				<hr />
				<custom:message></custom:message>
				<div class="step-content pos-rel">
					<div class="step-pane active" data-step="1">
						<h3 class="lighter block green">
						<fmt:message key="CodeGenerator.selectTable.title"/>
						<small>(<fmt:message key="CodeGenerator.selectTable.title.note"/>)</small>
						</h3>
						<fmt:message key="CodeGenerator.tableName.title" var="tableNameTitle"></fmt:message>
						<fmt:message key="CodeGenerator.tableComment.title" var="tableCommentTitle"></fmt:message>
						<form:form cssClass="form-horizontal" id="selectTableForm" action="${ctx }/codeGenerator/listColumnsForDataDict" method="post" modelAttribute="generatorSelect">
							<table id="dynamic-table" class="table table-responsive table-striped table-bordered table-hover dataTable">
								<thead>
									<tr>
										<th style="width:1px;"> </th>		
										<th style="width:1px;"><input type="checkbox" id="checkAll"></th>
										<th class="sorting" data-name="tableName">${tableNameTitle }</th>
										<th class="sorting" data-name="tableComment">${tableCommentTitle } </th>					
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${tableList}" var="item" varStatus="status">
										<tr>
											<td data-label="序号">${page.number * page.size + status.index + 1}</td>					
											<td><input type="checkbox" name="tableNames" value="${item.tableName}" class="checkitems"></td>	
											<td data-label="${tableNameTitle }"><c:out value='${item.tableName}'/>&nbsp;</td>
											<td data-label="${tableCommentTitle }"><c:out value='${item.tableComment}'/>&nbsp;</td>
										  </tr>
									</c:forEach>
								</tbody>
							</table>
						</form:form>
					</div>
				</div>
			</div>
			<hr/>
			<div class="wizard-actions">
				<button class="btn btn-success btn-next" data-last="Finish" id="nextButton">
					<fmt:message key="navigation.button.next"/>
					<i class="ace-icon fa fa-arrow-right icon-on-right"></i>
				</button>
			</div>
		</div>
	</div>
</div>